﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.answerinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int aid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(aid);
				}
			}
		}
			
	private void ShowInfo(int aid)
	{
		Maticsoft.BLL.answerinfo bll=new Maticsoft.BLL.answerinfo();
		Maticsoft.Model.answerinfo model=bll.GetModel(aid);
		this.lblaid.Text=model.aid.ToString();
		this.txtainfo.Text=model.ainfo;
		this.txtakey.Text=model.akey;
		this.txtascore.Text=model.ascore.ToString();
		this.txtstuType.Text=model.stuType;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtainfo.Text.Trim().Length==0)
			{
				strErr+="题干不能为空！\\n";	
			}
			if(this.txtakey.Text.Trim().Length==0)
			{
				strErr+="答案不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtascore.Text))
			{
				strErr+="分值格式错误！\\n";	
			}
			if(this.txtstuType.Text.Trim().Length==0)
			{
				strErr+="类别不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int aid=int.Parse(this.lblaid.Text);
			string ainfo=this.txtainfo.Text;
			string akey=this.txtakey.Text;
			decimal ascore=decimal.Parse(this.txtascore.Text);
			string stuType=this.txtstuType.Text;


			Maticsoft.Model.answerinfo model=new Maticsoft.Model.answerinfo();
			model.aid=aid;
			model.ainfo=ainfo;
			model.akey=akey;
			model.ascore=ascore;
			model.stuType=stuType;

			Maticsoft.BLL.answerinfo bll=new Maticsoft.BLL.answerinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
